﻿using NUnit.Framework;
using StreetPacMan.Server;
using StreetPacMan.Server.Infra;
using StreetPacMan.Server.Tests;

//must be in the root namespace to be run once before all tests
[SetUpFixture]
public class AssemblySetup
{
    [SetUp]
    public void Setup()
    {
        Bootstrapper.Bootstrap();
        Create();
    }

    private void Create()
    {
        using (var dbConnection = ConnectionProviderFactory.GetConnectionProvider().GetConnection())
        using (var pacManDataContext = new PacManDataContext(dbConnection))
        {
            if (pacManDataContext.DatabaseExists())
            {
                pacManDataContext.DeleteDatabase();
            }
            pacManDataContext.CreateDatabase();
        }
    }
}